//
//  GameOverScene.m
//  SimpleApp
//
//  Created by soonest on 12/5/12.
//
//

#import "GameOverScene.h"
#import "SimpleLayer.h"

@implementation GameOverScene
@synthesize layer = _layer;

- (id)init
{
    self = [super init];
    if (self) {
        self.layer = [GameOverLayer node];
        [self addChild:_layer];
    }
    return self;
}

- (void)dealloc
{
    [_layer release];
    _layer = nil;
    [super dealloc];
}

@end

@implementation GameOverLayer
@synthesize label = _label;

- (id)init
{
    self = [super initWithColor:ccc4(255, 255, 255, 255)];
    if (self) {
        CGSize winSize = [[CCDirector sharedDirector] winSize];
        self.label = [CCLabelTTF labelWithString:@"" fontName:@"Arial" fontSize:32];
        _label.color = ccc3(0, 0, 0);
        _label.position = ccp(winSize.width/2, winSize.height/2);
        [self addChild:_label];
        
        [self runAction:[CCSequence actions:[CCDelayTime actionWithDuration:3], [CCCallFuncN actionWithTarget:self selector:@selector(gameOverDone)], nil]];
    }
    return self;
}

- (void)gameOverDone
{
    [[CCDirector sharedDirector] replaceScene:[SimpleLayer scene]];
}

- (void)dealloc
{
    [_label release];
    _label = nil;
    [super dealloc];
}

@end
